"""通讯录页建模"""
from selenium.webdriver.common.by import By

from .base_page import BasePage

class ContactsPage(BasePage):
    _base_url = "https://work.weixin.qq.com/wework_admin/frame#contacts"

    def goto_add_member(self):
        # 如果出现A->B， B->A循环导入的场景，那么需要把其中一个的导包
        # 放到方法里面解决此问题。
        from .add_member_page import AddMemberPage
        return AddMemberPage(self.driver)

    def get_contacts_list(self):
        """ 返回通讯录列表"""
        phone_eles = self.driver.find_elements(By.CSS_SELECTOR,"#member_list tr td:nth-child(5)")
        phone_list = [x.text.strip() for x in phone_eles if x.text.strip()!=""]
        return phone_list

